﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace KokosSearcher
{
	public partial class FilterGroup : UserControl
	{
		private SearchParameters _searchParams = new SearchParameters();

		public SearchParameters SearchParams{
			get {return this._searchParams;}
		}

		public FilterGroup()
		{
			InitializeComponent();
		}

		/// <summary>
		/// Sets all the properties fo SearchParams
		/// </summary>
		private void setSearchPArameters()
		{
			foreach (Control filterBox in this.Controls)
			{
				if (filterBox.GetType() == typeof(TextBox))
				{
					switch (filterBox.Tag.ToString().ToLower())
					{
						case "user":
							this._searchParams.User = filterBox.Text;
							break;
						case "title":
							this._searchParams.Title = filterBox.Text;
							break;
						case "valuefrom":
							this._searchParams.ValueFrom = filterBox.Text;
							break;
						case "valueto":
							this._searchParams.ValueTo = filterBox.Text;
							break;
						case "periodfrom":
							this._searchParams.PeriodFrom = filterBox.Text;
							break;
						case "periodto":
							this._searchParams.PeriodTo = filterBox.Text;
							break;
						case "percentfrom":
							this._searchParams.PercentFrom = filterBox.Text;
							break;
						case "percentto":
							this._searchParams.PercentTo = filterBox.Text;
							break;
						case "realizationfrom":
							this._searchParams.RealizationFrom = filterBox.Text;
							break;
						case "realizationto":
							this._searchParams.RealizationTo = filterBox.Text;
							break;
						case "investorsamountfrom":
							this._searchParams.InvestorsAmountFrom = filterBox.Text;
							break;
						case "investorsamountto":
							this._searchParams.InvestorsAmountTo = filterBox.Text;
							break;
						default:
							break;
					}
				}

				if (filterBox.GetType() == typeof(NumericUpDown))
				{
					this._searchParams.Page = filterBox.Text;
				}
			}
		}
	}
}
